/**
 * 基础菜单 采购管理
 */
<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>审核管理</el-breadcrumb-item>
      <el-breadcrumb-item>审核计划</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 搜索筛选 -->
    <el-form :inline="true" :model="formInline" class="user-search">
      <!-- <el-form-item>
        <el-button
          size="small"
          type="primary"
          icon="el-icon-plus"
          @click="TestClick()"
          >测试</el-button
        >
      </el-form-item> -->
    </el-form>
    <!--需要审核的列表 begin-->
    <el-table
      size="small"
      :data="AuditLogginList"
      highlight-current-row
      v-loading="loading"
      border
      element-loading-text="拼命加载中"
      style="width: 100%"
    >
      <el-table-column align="center" type="selection" width="60">
      </el-table-column>
      <el-table-column sortable prop="id" label="编号" width="150">
      </el-table-column>
      <el-table-column sortable prop="userInfosId" label="审批人" width="150">
      </el-table-column>
      <el-table-column sortable prop="wenJianId" label="审批文件" width="150">
      </el-table-column>
      <el-table-column sortable prop="idea" label="意见" width="150">
      </el-table-column>
      <!-- <el-table-column sortable prop="Reorder" label="顺序" width="150">
      </el-table-column> -->
      <el-table-column sortable prop="auditStatus" label="审核状态" width="150">
      </el-table-column>
      <el-table-column sortable prop="createTime" label="创建时间" width="150">
      </el-table-column>

      <el-table-column
        fixed="right"
        align="center"
        label="操作"
        min-width="100"
      >
        <template slot-scope="scope">
          <el-button type="text" @click="CheckClick(scope.row)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <Pagination
      v-bind:child-msg="pageparm"
      @callFather="callFather"
    ></Pagination>
    <!-- 查看事件 对话框 begin-->
    <el-dialog
      title="采购计划"
      :visible.sync="CheckCaigouPlanDialog"
      width="70%"
    >
      <template>
        <el-table :data="PlanList" border style="width: 100%">
          <el-table-column align="center" type="selection" width="60">
          </el-table-column>
          <el-table-column sortable prop="id" label="编号" width="150">
          </el-table-column>
          <el-table-column sortable prop="depart" label="部门" width="150">
          </el-table-column>
          <el-table-column
            sortable
            prop="planDate"
            label="计划日期"
            width="150"
          >
          </el-table-column>
          <el-table-column sortable prop="plannerID" label="计划人" width="150">
          </el-table-column>
          <el-table-column sortable prop="others" label="备注" width="150">
          </el-table-column>
          <el-table-column
            sortable
            prop="operatorID"
            label="操作人"
            width="150"
          >
          </el-table-column>
          <el-table-column sortable prop="inDate" label="录入日期" width="150">
          </el-table-column>
          <el-table-column
            sortable
            prop="examinerID"
            label="审核人"
            width="150"
          >
          </el-table-column>
          <el-table-column sortable prop="inDate" label="录入日期" width="150">
          </el-table-column>

          <el-table-column
            fixed="right"
            align="center"
            label="操作"
            min-width="100"
          >
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                @click="CheckDetailClick(scope.row)"
                >查看采购计划明细</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </template>
      <span slot="footer" class="dialog-footer">
        <el-button @click="CheckCaigouPlanDialog = false">取 消</el-button>
        <el-button type="primary" @click="CheckCaigouPlanDialog = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <!-- 查看事件 对话框 end-->
    <!-- 查看采购计划明细 对话框 begin -->
    <el-dialog title="计划明细" :visible.sync="CheckDetailDialog" width="80%">
      <template>
        <el-table :data="PlanDetailList" border style="width: 100%">
          <el-table-column align="center" type="selection" width="60">
          </el-table-column>
          <el-table-column sortable prop="id" label="编号" width="150">
          </el-table-column>
          <el-table-column
            sortable
            prop="planID"
            label="采购计划单号"
            width="150"
          >
          </el-table-column>
          <el-table-column
            sortable
            prop="commodityInformationSheetId"
            label="商品编号"
            width="150"
          >
          </el-table-column>
          <el-table-column sortable prop="quantity" label="数量" width="150">
          </el-table-column>
          <el-table-column sortable prop="others" label="备注" width="150">
          </el-table-column>
        </el-table>
      </template>
      <span slot="footer" class="dialog-footer">
        <el-button @click="CheckDetailDialog = false">驳回</el-button>
        <el-button type="primary" @click="ApproveClick">通过</el-button>
      </span>
    </el-dialog>
    <!-- 查看采购计划明细 对话框 end -->
  </div>
</template>
     

<script>
import Pagination from "../../components/Pagination";

import {
  CaiGouPlan,
  CaiGouPlanList,
  CaiGouPlanDetails,
  GetAuditLoggingList,
  Approve,
} from "../../api/likai";
import Axios from "axios";
export default {
  data() {
    return {
      CheckCaigouPlanDialog: false, //控制采购计划对话框的显示与隐藏
      //AuditLoggingForm
      AuditLoggingForm: {
        Id: "",
        UserInfosId: "",
        WenJianId: "",
        Idea: "",
        Reorder: "",
        AuditStatus: "",
        CreateTime: "",
      },
      //获取需要审批列表的参数
      GetAuditLoggingFrom: {
        userInfosId: "",
      },
      PlanDetailList: [], //计划明细列表
      //审核需要的参数表单
      ApproveForm: {
        AuditLoggingId: "",
        Reorder: "",
        WenJianId: "",
      },
      CheckDetailDialog: false, //控制计划明细对话框的显示与隐藏
      PlanList: [], //采购计划列表
      dialogVisible: false,
      AuditLogginList: [], //需要审核的列表
      PlannerList: [], //计划人列表
      OperatorList: [], //操作人列表
      form: {},
      nshow: true, //switch开启
      fshow: false, //switch关闭
      loading: false, //是显示加载
      // rules表单验证
      rules: {
        deptName: [
          { required: true, message: "请输入部门名称", trigger: "blur" },
        ],
        deptNo: [
          { required: true, message: "请输入部门代码", trigger: "blur" },
        ],
      },
      formInline: {
        // page: 1,
        // limit: 10,
        // varLable: "",
        // varName: "",
        // token: localStorage.getItem("logintoken"),
        Name: "123",
      },
      userparm: [], //搜索权限
      listData: [], //用户数据
      ShopList: [], //商品数据
      // 分页参数
      pageparm: {
        currentPage: 1,
        pageSize: 10,
        total: 10,
      },
    };
  },
  // 注册组件
  components: {
    Pagination,
  },

  /**
   * 创建完毕
   */
  created() {
    this.GetAuditLoggingFrom.userInfosId =
      "C0668738-5055-40A2-9F06-CF63F1D265A6";
    this.getdata(this.GetAuditLoggingFrom);
    this.ApproveForm.AuditLoggingId = "C0668738-5055-40A2-9F06-CF63F1D265A6";
  },

  methods: {
    getdata(parameter) {
      this.loading = true;

      GetAuditLoggingList(parameter)
        .then((res) => {
          this.loading = false;
          this.AuditLogginList = res;
        })
        .catch((err) => {
          this.loading = false;
          this.$message.error("菜单加载失败，请稍后再试！");
        });
    },
    TestClick() {
      this.getdata(this.GetAuditLoggingFrom);
    },
    // 分页插件事件
    callFather(parm) {
      this.formInline.page = parm.currentPage;
      this.formInline.limit = parm.pageSize;
      this.getdata(this.formInline);
    },
    // 搜索事件
    search() {
      this.getdata(this.formInline);
    },

    //查看采购计划事件
    CheckClick(row) {
      console.log("输出本行数据");
      console.log(row);
      this.AuditLoggingForm = row;
      console.log(this.AuditLoggingForm);

      CaiGouPlan(row.wenJianId).then((res) => {
        // console.log(res);
        this.PlanList = res;
      });
      this.CheckCaigouPlanDialog = true;
    },
    //查看采购计划明细事件
    CheckDetailClick(row) {
      this.ApproveForm.WenJianId = row.id;
      CaiGouPlanDetails(row.id)
        .then((res) => {
          if (res == null) {
          } else {
            this.$message({
              type: "success",
              message: "获取数据成功了",
            });
            this.PlanDetailList = res;
          }
        })
        .catch((err) => {
          this.loading = false;
          this.$message.error("菜单加载失败，请稍后再试！");
        });
      this.CheckDetailDialog = true;
    },
    ApproveClick() {
      console.log("进入了通过事件");
      this.AuditLoggingForm.AuditStatus = 2;
      Approve(this.AuditLoggingForm)
        .then((res) => {
          if (res == null) {
          } else {
            this.$message({
              type: "success",
              message: "获取数据成功了",
            });
            this.getdata(this.GetAuditLoggingFrom);
            this.CheckDetailDialog = false;
            this.CheckCaigouPlanDialog=false;
          }
        })
        .catch((err) => {
          this.loading = false;
          this.$message.error("菜单加载失败，请稍后再试！");
        });
    },
  },
};
</script>

<style scoped>
.user-search {
  margin-top: 20px;
}
.userRole {
  width: 100%;
}
</style>

 
 